# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This package provides simple traffic sending and validation capabilities
# through the GenericTestbed and the ControlDevice.

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "basic_p4rt_util",
    srcs = ["basic_p4rt_util.cc"],
    hdrs = ["basic_p4rt_util.h"],
    deps = [
        "//gutil/gutil:proto",
        "//p4_pdpi:ir_cc_proto",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi:pd",
        "//p4_pdpi/packetlib:packetlib_cc_proto",
        "//sai_p4/instantiations/google:instantiations",
        "//sai_p4/instantiations/google:sai_p4info_cc",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/functional:bind_front",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_test(
    name = "basic_p4rt_util_test",
    srcs = ["basic_p4rt_util_test.cc"],
    deps = [
        ":basic_p4rt_util",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//p4_pdpi:p4_runtime_session",
        "//sai_p4/instantiations/google:instantiations",
        "//sai_p4/instantiations/google:sai_p4info_cc",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "basic_traffic",
    testonly = True,
    srcs = ["basic_traffic.cc"],
    hdrs = ["basic_traffic.h"],
    deps = [
        ":basic_p4rt_util",
        "//gutil/gutil:collections",
        "//lib/gnmi:gnmi_helper",
        "//lib/p4rt:p4rt_programming_context",
        "//lib/utils:generic_testbed_utils",
        "//p4_pdpi:ir_cc_proto",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi/packetlib",
        "//p4_pdpi/packetlib:packetlib_cc_proto",
        "//thinkit:control_device",
        "//thinkit:generic_testbed",
        "//thinkit:switch",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "basic_traffic_test",
    srcs = ["basic_traffic_test.cc"],
    deps = [
        ":basic_traffic",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi/packetlib",
        "//p4_pdpi/packetlib:packetlib_cc_proto",
        "//sai_p4/instantiations/google:instantiations",
        "//sai_p4/instantiations/google:sai_p4info_cc",
        "//thinkit:control_device",
        "//thinkit:generic_testbed",
        "//thinkit:mock_control_device",
        "//thinkit:mock_generic_testbed",
        "//thinkit:mock_switch",
        "//thinkit:packet_generation_finalizer",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@com_google_googletest//:gtest_main",
    ],
)
